require("../../resource/js/htmlToWxml.js"), require("../../resource/js/images.js");

var e = getApp();

Page({
    data: {
        showmsg: !0
    },
    onLoad: function(e) {
        wx.setNavigationBarTitle({
            title: "会员中心"
        });
    },
    onReady: function() {},
    toOrderlist: function(e) {
        var o = e.currentTarget.dataset.id;
        console.log(o), wx.navigateTo({
            url: "/weixinmao_house/pages/orderlist/index?id=" + o
        });
    },
    toMypub: function(e) {
        var o = e.currentTarget.dataset.id;
        console.log(o), wx.navigateTo({
            url: "/weixinmao_house/pages/mypub/index?id=" + o
        });
    },
    toMyletpub: function(e) {
        var o = e.currentTarget.dataset.id;
        console.log(o), wx.navigateTo({
            url: "/weixinmao_house/pages/myletpub/index?id=" + o
        });
    },
    toMysalepub: function(e) {
        var o = e.currentTarget.dataset.id;
        console.log(o), wx.navigateTo({
            url: "/weixinmao_house/pages/mysalepub/index?id=" + o
        });
    },
    onShow: function() {
        var e = this;
        this.checkuser({
            doServices: function() {
                var o = wx.getStorageSync("userInfo");
                console.log(o.wxInfo), e.setData({
                    userinfo: o
                });
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    binduserinfo: function(o) {
        var s = this;
        s.data.showmsg = !1;
        var t = wx.getStorageSync("userInfo");
        e.util.request({
            url: "entry/wxapp/getuserinfo",
            data: {
                sessionid: t.sessionid,
                uid: t.memberInfo.uid
            },
            success: function(e) {
                s.setData({
                    user: e.data.data,
                    showmsg: s.data.showmsg
                });
            }
        });
    },
    saveuserinfo: function(o) {
        var s = this, t = o.detail.value.name, n = o.detail.value.tel;
        s.data.showmsg = !0;
        var a = wx.getStorageSync("userInfo");
        "" != t ? "" != n ? e.util.request({
            url: "entry/wxapp/saveuserinfo",
            data: {
                sessionid: a.sessionid,
                uid: a.memberInfo.uid,
                name: t,
                tel: n
            },
            success: function(e) {
                if (0 != e.data.errno) return wx.hideLoading(), void wx.showModal({
                    title: "失败",
                    content: e.data.msg,
                    showCancel: !1
                });
                wx.showToast({
                    title: "操作成功",
                    icon: "success",
                    duration: 2e3
                }), s.setData({
                    showmsg: s.data.showmsg
                });
            }
        }) : wx.showModal({
            title: "提示",
            content: "请填写您的手机号",
            showCancel: !1
        }) : wx.showModal({
            title: "提示",
            content: "请填写您的姓名",
            showCancel: !1
        });
    },
    closemsg: function(e) {
        this.data.showmsg = !0, this.setData({
            showmsg: this.data.showmsg
        });
    },
    onReachBottom: function() {},
    toMycouponlist: function(e) {
        wx.navigateTo({
            url: "/weixinmao_house/pages/couponlist/index"
        });
    },
    Puboldhouse: function(e) {
        wx.navigateTo({
            url: "/weixinmao_house/pages/pub/index"
        });
    },
    onShareAppMessage: function() {},
    checkuser: function(o) {
        var s = this, o = o, t = wx.getStorageSync("userInfo");
        return t ? t.memberInfo.uid ? void e.util.request({
            url: "entry/wxapp/checkuserinfo",
            data: {
                sessionid: t.sessionid,
                uid: t.memberInfo.uid
            },
            success: function(e) {
                0 == e.data.data.error ? (console.log(o), o.doServices()) : 2 == e.data.data.error && o.doServices();
            }
        }) : (console.log("tmddddsssssqqqqs1111"), e.util.getUserInfo(function(e) {
            s.setData({
                userinfo: e
            });
        }), !1) : (console.log("tmddddssssss222222"), e.util.getUserInfo(function(e) {
            s.setData({
                userinfo: e
            });
        }), !1);
    }
});